package org.domain.prosoft.session;

import org.domain.prosoft.session.*;
import java.util.ArrayList;
import java.util.List;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("incidenteHome")
public class IncidenteHome extends EntityHome<Incidente> {

	@In(create = true)
	UsuarioHome usuarioHome;

	public void setIncidenteId(Long id) {
		setId(id);
	}

	public Long getIncidenteId() {
		return (Long) getId();
	}

	@Override
	protected Incidente createInstance() {
		Incidente incidente = new Incidente();
		return incidente;
	}

	public void wire() {
		getInstance();
		Usuario criador = usuarioHome.getDefinedInstance();
		if (criador != null) {
			getInstance().setCriador(criador);
		}
	}

	public boolean isWired() {
		return true;
	}

	public Incidente getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

	public List<Resposta> getRespostas() {
		return getInstance() == null ? null : new ArrayList<Resposta>(
				getInstance().getRespostas());
	}

}
